package com.soft.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.soft.entity.Dept;
import com.soft.entity.Good;
import com.soft.mapper.GoodMapper;

@Service
public class GoodService {
    @Autowired
    private GoodMapper goodMapper;
    
    public List<Good> queryAll() {
        List<Good> goodList = goodMapper.selectList(null);
        return goodList;
    }
    public List<Good>queryByGoodName(String goodName)
    {
    	QueryWrapper<Good> qw = new QueryWrapper<>();
    	qw.eq("good_name", goodName);
    	List<Good> goodList = goodMapper.selectList(qw);
    	return goodList;
    }
    public int insertOne(String goodName, String goodPrice) {
        Good good = new Good();
        good.setGoodName("goodName");
        good.setGoodPrice("6666");
        int num = goodMapper.insert(good);
        return num;
    }

    public int deleteById(String id) {
        Good good = new Good();
        good.setGoodId(id);
        int num = goodMapper.deleteById(good);
        return num;
    }
    public int deleteByName(String name)
	{
		QueryWrapper<Good> qw = new QueryWrapper();
		qw.eq("good_name", name);
		return goodMapper.delete(qw);
	}
    }